import javax.swing.tree.TreeNode;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DELL
 * Date: 2022-10-05
 * Time: 19:24
 */
public class Test_MyBinaryTree {
    public static void main1(String[] args) {
        MyBinaryTree myBinaryTree = new MyBinaryTree();
        MyBinaryTree.TreeNode root = myBinaryTree.createTree();
        myBinaryTree.preOrder(root);
        System.out.println();
        myBinaryTree.inOrder(root);
        System.out.println();
        myBinaryTree.postOrde(root);
        System.out.println();
        System.out.print("节点个数为：");
        System.out.println(myBinaryTree.size(root));
        System.out.println();
        System.out.print("叶子节点的个数为：");
        System.out.println(myBinaryTree.getLeafNodeCount(root));
        int k = 3;
        System.out.println();
        System.out.print("第" + k + "层的节点个数为：");
        System.out.println(myBinaryTree.getKLevelNodeCount(root, k));
        System.out.println();
        System.out.print("树的高度：");
        System.out.println(myBinaryTree.getHeight(root));
        myBinaryTree.levelOrder1(root);
        System.out.println();
        myBinaryTree.levelOrder(root);
        System.out.println();
        boolean x = myBinaryTree.isCompleteTree(root);
        System.out.println(x);

    }


    public static void main2(String[] args) {
        MyBinaryTree myBinaryTree = new MyBinaryTree();
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) {
            // 注意 while 处理多个 case
            String str = in.nextLine(); // 有空格 使用 nextLine

            MyBinaryTree.TreeNode root = myBinaryTree.createTree(str);
            //将此根节点进行中序遍历
            myBinaryTree.inorder(root);
        }
    }

    public static void main3(String[] args) {
        int[] inorder = {9,3,15,20,7};
        int [] postorder = {9,15,7,20,3};
        MyBinaryTree myBinaryTree = new MyBinaryTree();
        TreeNode root = (TreeNode) myBinaryTree.buildTree(inorder,postorder);
    }

    public static void main(String[] args) {
        MyBinaryTree myBinaryTree = new MyBinaryTree();
        MyBinaryTree.TreeNode root = myBinaryTree.createTree();
        System.out.println(myBinaryTree.preorderTraversal(root).toString());

        System.out.println(myBinaryTree.getKLevelNodeCount(root, 4));
    }
}
